package camel.corp.universalcopy.a;

import android.app.Activity;
import android.util.Log;
import com.android.billingclient.api.d;
import com.android.billingclient.api.j;
import com.android.billingclient.api.k;
import com.camel.corp.universalcopy.a.a;
import com.camel.corp.universalcopy.a.b;
import com.camel.corp.universalcopy.a.c;
import com.camel.corp.universalcopy.a.d;
import com.camel.corp.universalcopy.a.e;
import com.camel.corp.universalcopy.a.f;
import com.camel.corp.universalcopy.a.l;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class f implements k {
  private final a a;
  
  private final Activity b;
  
  private final List<j> c = new ArrayList();
  
  private d d;
  
  private boolean e;
  
  private int f = -1;
  
  public f(Activity paramActivity, a parama) {
    Log.d("BillingManager", "Creating Billing client.");
    this.b = paramActivity;
    this.a = parama;
    d.a a1 = d.a(this.b);
    a1.a(this);
    this.d = a1.a();
    Log.d("BillingManager", "Starting setup.");
    a(new b(this));
  }
  
  private void a(j.a parama) {
    if (this.d == null || parama.b() != 0) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("Billing client was null or result code (");
      stringBuilder.append(parama.b());
      stringBuilder.append(") was bad - quitting");
      Log.w("BillingManager", stringBuilder.toString());
      return;
    } 
    Log.d("BillingManager", "Query inventory was successful.");
    this.c.clear();
    a(0, parama.a());
  }
  
  private void a(j paramj) {
    if (!b(paramj.a(), paramj.d())) {
      StringBuilder stringBuilder1 = new StringBuilder();
      stringBuilder1.append("Got a purchase: ");
      stringBuilder1.append(paramj);
      stringBuilder1.append("; but signature is bad. Skipping...");
      Log.i("BillingManager", stringBuilder1.toString());
      return;
    } 
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("Got a verified purchase: ");
    stringBuilder.append(paramj);
    Log.d("BillingManager", stringBuilder.toString());
    this.c.add(paramj);
  }
  
  private void b(Runnable paramRunnable) {
    if (this.e) {
      paramRunnable.run();
      return;
    } 
    a(paramRunnable);
  }
  
  private boolean b(String paramString1, String paramString2) {
    try {
      return l.a(a.a(), paramString1, paramString2);
    } catch (IOException paramString1) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("Got an exception trying to validate a purchase: ");
      stringBuilder.append(paramString1);
      Log.e("BillingManager", stringBuilder.toString());
      return false;
    } 
  }
  
  public void a(int paramInt, List<j> paramList) {
    if (paramInt == 0) {
      Iterator iterator = paramList.iterator();
      while (iterator.hasNext())
        a((j)iterator.next()); 
      this.a.a(this.c);
      return;
    } 
    if (paramInt == 1) {
      Log.i("BillingManager", "onPurchasesUpdated() - user cancelled the purchase flow - skipping");
      return;
    } 
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("onPurchasesUpdated() got unknown resultCode: ");
    stringBuilder.append(paramInt);
    Log.w("BillingManager", stringBuilder.toString());
  }
  
  public void a(Runnable paramRunnable) { this.d.a(new e(this, paramRunnable)); }
  
  public void a(String paramString1, String paramString2) { a(paramString1, null, paramString2); }
  
  public void a(String paramString1, ArrayList<String> paramArrayList, String paramString2) { b(new c(this, paramArrayList, paramString1, paramString2)); }
  
  public boolean a() {
    int i = this.d.a("subscriptions");
    if (i != 0) {
      StringBuilder stringBuilder = new StringBuilder();
      stringBuilder.append("areSubscriptionsSupported() got an error response: ");
      stringBuilder.append(i);
      Log.w("BillingManager", stringBuilder.toString());
    } 
    return (i == 0);
  }
  
  public void b() {
    Log.d("BillingManager", "Destroying the manager.");
    d d1 = this.d;
    if (d1 != null && d1.b()) {
      this.d.a();
      this.d = null;
    } 
  }
  
  public int c() { return this.f; }
  
  public void d() { b(new d(this)); }
}


/* Location:              D:\Users\alienware\AndroidStudioProjects\Lazero\sample\sampler\classes-dex2jar\com\camel.jar!\camel\cor\\universalcopy\a\f.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.0.7
 */